package com.bhs.sansonglogistics.ui.adapter;

import android.icu.text.IDNA;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.AbnormalOrderBean;
import com.bhs.sansonglogistics.utils.DateUtils;
import com.bhs.sansonglogistics.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class AbnormalOrderAdapter extends BaseQuickAdapter<AbnormalOrderBean.DataDTO.ListDTO, BaseViewHolder> {

    public AbnormalOrderAdapter() {
        super(R.layout.item_abnormal_order);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, AbnormalOrderBean.DataDTO.ListDTO item) {
        helper.addOnClickListener(R.id.btn_dispose, R.id.btn_payment, R.id.tv_phone, R.id.btn_check,R.id.iv_phone);
        helper.setGone(R.id.btn_dispose, item.getStatus().equals("1"));
       // helper.setGone(R.id.btn_payment, item.getStatus().equals("5"));
        helper.setGone(R.id.btn_check, !item.getStatus().equals("1"));
        AbnormalOrderBean.DataDTO.ListDTO.DeliverInfoDTO info = item.getDeliver_info();
        helper.setText(R.id.tv_ship_address, info.getPickup_city());
        helper.setText(R.id.tv_pick_up_address, info.getReceive_city());
        helper.setText(R.id.tv_order_number, String.format("异常单号：%s", item.getOrder_sn()));
        helper.setText(R.id.tv_goods_info, String.format("货物信息：%s/%s件/%s吨/%s立方", info.getGoods_name(), info.getGoods_number(),
                MyUtils.checkPoint(info.getGoods_weight()), MyUtils.checkPoint(info.getGoods_volume())));
        helper.setText(R.id.tv_type, String.format("投诉类型：%s", item.getType()));
        helper.setText(R.id.tv_time, String.format("投诉时间：%s", DateUtils.getTime(item.getCreate_time())));
        helper.setText(R.id.tv_phone, String.format("客户电话：%s", item.getCargo_info().getMobile()));

        if (item.getStatus().equals("7")) {
            helper.setText(R.id.tv_status, "处理完成");
            helper.setImageResource(R.id.iv_status, R.mipmap.ic_figure_out);
        } else if (item.getStatus().equals("9")) {
            helper.setText(R.id.tv_status, "已撤销");
            helper.setImageResource(R.id.iv_status, R.mipmap.ic_revocation);
        } else {
            helper.setText(R.id.tv_status, "处理中");
            helper.setImageResource(R.id.iv_status, R.mipmap.ic_pending);
        }
    }
}
